import type { RowType } from '#/views/system/permission/permission.data';

import { requestClient } from '#/api/request';

export namespace SysPermissionTableApi {
  export type RowTypeFetchParams = RowType;
  export interface IdFetchParams {
    id: string;
  }
  export interface ListFetchParams {
    [key: string]: any;
  }
  export interface PageListFetchParams {
    [key: string]: any;
    pageNo: number;
    pageSize: number;
  }
}

/**
 * 懒加载列表查询
 */
export async function permissionQueryLazyListApi(
  params: SysPermissionTableApi.ListFetchParams,
) {
  return requestClient.get('/sys/permission/queryLazyList', { params });
}

/**
 * 列表查询
 */
export async function permissionQueryListApi(
  params: SysPermissionTableApi.ListFetchParams,
) {
  return requestClient.get('/sys/permission/queryList', { params });
}

/**
 * 通过ID查询
 * @param params
 */
export async function permissionQueryByIdApi(
  params: SysPermissionTableApi.IdFetchParams,
) {
  return requestClient.get('/sys/permission/queryById', { params });
}

/**
 * 新增
 */
export async function permissionAddApi(
  params: SysPermissionTableApi.RowTypeFetchParams,
) {
  return requestClient.post('/sys/permission/add', params);
}

/**
 * 编辑
 */
export async function permissionEditApi(
  params: SysPermissionTableApi.RowTypeFetchParams,
) {
  return requestClient.post('/sys/permission/edit', params);
}

/**
 * 删除
 * @param id 主键
 */
export async function permissionDelApi(id) {
  return requestClient.delete<boolean>(`/sys/permission/delete/${id}`);
}

/**
 * 代码生成中菜单生成接口
 * @param params
 */
export async function permissionGenMenuItemApi(params) {
  return requestClient.get('/sys/permission/genMenuItem', { params });
}
